package com.yami.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yami.shop.bean.model.SpuSeriesRelation;
import com.yami.shop.dao.SpuSeriesRelationMapper;
import com.yami.shop.service.SpuSeriesRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class SpuSeriesRelationServiceImpl extends ServiceImpl<SpuSeriesRelationMapper, SpuSeriesRelation> implements SpuSeriesRelationService {

    @Autowired
    private SpuSeriesRelationMapper spuSeriesRelationMapper;
    
    @Override
    public SpuSeriesRelation getInfoByproductId(Integer productId) {
        QueryWrapper<SpuSeriesRelation> spuSeriesRelationQueryWrapper = new QueryWrapper<>();
        spuSeriesRelationQueryWrapper.eq("product_id",productId);
        SpuSeriesRelation spuSeriesRelation = spuSeriesRelationMapper.selectOne(spuSeriesRelationQueryWrapper);
        return spuSeriesRelation;
    }

    @Override
    @Transactional
    public void deleByproductId(Integer productId) {
        QueryWrapper<SpuSeriesRelation> spuSeriesRelationQueryWrapper = new QueryWrapper<>();
        spuSeriesRelationQueryWrapper.eq("product_id", productId);
        spuSeriesRelationMapper.delete(spuSeriesRelationQueryWrapper);
    }
}
